﻿using WindowsGame.GameObject;
using Microsoft.Xna.Framework;

namespace WindowsGame.Manager
{
	/// <summary>
	/// GameObjectManager is responsible for managing all objects in game.
	/// </summary>
	public interface IGameObjectManager
	{
		void LoadContent();
		void Update(GameTime gameTime);
		void Draw();
	}

	public class GameObjectManager : IGameObjectManager
	{
		// GameObjectManager has dependency on CameraManager and ContentManager.
		private readonly ICameraManager cameraManager;
		private readonly IContentManager contentManager;
		private readonly SpaceShip spaceShip;

		public GameObjectManager(ICameraManager cameraManager, IContentManager contentManager)
		{
			this.cameraManager = cameraManager;
			this.contentManager = contentManager;
			spaceShip = new SpaceShip();
		}

		// Load content for each game object.
		public void LoadContent()
		{
			spaceShip.LoadContent(contentManager.SpaceShipModel, cameraManager.ViewMatrix, cameraManager.ProjectionMatrix);
		}

		// Update each game object.
		public void Update(GameTime gameTime)
		{
			spaceShip.Update(gameTime);
		}

		// Draw each game object.
		public void Draw()
		{
			spaceShip.Draw();
		}
	}
}